//
//  WSDietTableViewCell.m
//  RunningMan
//
//  Created by 王帅 on 16/5/18.
//  Copyright © 2016年 WSJ. All rights reserved.
//

#import "WSDietTableViewCell.h"
#import "WSMyTool.h"
// 把外界不需要访问的属性写在 .m 文件的延展里
@interface WSDietTableViewCell ()
@property (nonatomic, strong) UIImageView *imageViewPhoto;
@property (nonatomic, strong) UILabel *lableTitle;
@property (nonatomic, strong) UILabel *lableContent;
@property (nonatomic, strong) UILabel *lableCommentCount;
@property (nonatomic, strong) UILabel *lableFavCount;
@property (nonatomic, strong) UILabel *lablePraiseCount;
@end

@implementation WSDietTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}
- (void)createSubView {
    self.imageViewPhoto = [[UIImageView alloc] init];
//    self.imageViewPhoto.layer.masksToBounds = YES;
    [self.contentView addSubview:self.imageViewPhoto];
    
    self.lableTitle = [[UILabel alloc] init];
    self.lableTitle.font = [UIFont systemFontOfSize:17 * FITWIDTH];
    [self.contentView addSubview:self.lableTitle];
    
    self.lableContent = [[UILabel alloc] initWithFrame:CGRectZero];
    self.lableContent.font = [UIFont systemFontOfSize:14 * FITWIDTH];
    self.lableContent.numberOfLines = 0;
    self.lableContent.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.lableContent];
    
    self.lableCommentCount = [[UILabel alloc] initWithFrame:CGRectZero];
    self.lableCommentCount.font = [UIFont systemFontOfSize:15 * FITWIDTH];
    self.lableCommentCount.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.lableCommentCount];
    
    self.lableFavCount = [[UILabel alloc] initWithFrame:CGRectZero];
    self.lableFavCount.font = [UIFont systemFontOfSize:15 * FITWIDTH];
    self.lableFavCount.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.lableFavCount];
    
    self.lablePraiseCount = [[UILabel alloc] initWithFrame:CGRectZero];
    self.lablePraiseCount.font = [UIFont systemFontOfSize:15 * FITWIDTH];
    self.lablePraiseCount.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.lablePraiseCount];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageViewPhoto.frame = CGRectMake(10 * FITWIDTH,10 * FITHEIGHT, 120 * FITWIDTH, 95 * FITHEIGHT);
    self.lableTitle.frame = CGRectMake(140 * FITWIDTH, 10 * FITHEIGHT, 260 * FITWIDTH, 15 * FITHEIGHT);
    self.lableContent.frame = CGRectMake(140 * FITWIDTH, 35 * FITHEIGHT, 260 * FITWIDTH, 40 * FITHEIGHT);
    self.lableCommentCount.frame = CGRectMake(140 * FITWIDTH, 85 * FITHEIGHT, 140 * FITWIDTH, 25 * FITHEIGHT);
    self.lableFavCount.frame = CGRectMake(240 * FITWIDTH, 85 * FITHEIGHT, 140 * FITWIDTH, 25 * FITHEIGHT);
    self.lablePraiseCount.frame = CGRectMake(340 * FITWIDTH, 85 * FITHEIGHT, 140 * FITWIDTH, 25 * FITHEIGHT);
}
- (void)setModel:(Infos *)model {
    _model = model;
    NSArray *arr = [model.photo componentsSeparatedByString:@"/"];
    NSString *str = [arr componentsJoinedByString:@".fit-time.cn/"];
    NSString *str1 = @"http://";
    NSString *url = [str1 stringByAppendingString:str];
    [self.imageViewPhoto sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"允儿副本"]];
    self.lableTitle.text = model.title;
    self.lableContent.text = model.content;
    self.lableCommentCount.text = [NSString stringWithFormat:@"评论: %@", model.commentCount];
    self.lableFavCount.text = [NSString stringWithFormat:@"收藏: %@",model.favCount];
    self.lablePraiseCount.text = [NSString stringWithFormat:@"赞: %@",model.praiseCount];
    
}
@end
